package com.qfedu.labsystem.config;

import com.qfedu.labsystem.entity.vo.ResultOBJ;
import com.qfedu.labsystem.exception.BusinessRuntimeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

/**
 * 全局异常处理器
 *
 * @ClassName GlobalExceptionHandleConfig
 * @Author ykx
 * @Date 2024/4/8 22:40
 * @Version 1.0
 */
@ControllerAdvice
@RestController
@Slf4j
public class GlobalExceptionHandleConfig {
    @ExceptionHandler(value = BusinessRuntimeException.class)
    public ResultOBJ BusinessRuntimeExceptionErrorHandle(BusinessRuntimeException e) {
        log.info(e.getMessage());
        return ResultOBJ.failed(e.getMsg());
    }
}
